﻿#include <Sys\RenderUnit\SysRenderDatagram\ANCHORRD.HPP>
#include <Render\Render_Win32\Render_Win32_OpenGL\RENDER_WIN32_OPENGL.HPP>
#include <Sys\RenderUnit\SYSDDCLASSID.HPP>


using namespace CxxlMan;
using namespace Cxxl3D;

class CAnchorDD_OpenGL:public IDatagramDisposal_OpenGL
{
  virtual bool cxxlFASTCALL Exec(const Smart_Ptr<IRenderDatagramDisposalCenterOpengl> &IRenderDatagramDisposalCenter_Arg,
    const Smart_Ptr<IRenderDatagram> &IRenderDatagram_Arg, const CxxlMan::CSmart_Ptr<Matrix4x4> &ViewMatrix_Arg)
  {
    Smart_Ptr<IAnchorRD> IAnchorRD_Ptr = (IAnchorRD*)GetDefaultInterface(IRenderDatagram_Arg);
    Smart_Ptr<IC3D_Node> IC3D_Node_Ptr = IAnchorRD_Ptr->Get_IC3D_Node();
    CSmart_Ptr<const Matrix4x4> WorldMatrix_cPtr = IC3D_Node_Ptr->GetWorldMatrix();

    Matrix4x4 WorldViewMatrix = (*WorldMatrix_cPtr) * (*ViewMatrix_Arg);
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixf((C3D_FLOAT*)(Matrix4x4*)&WorldViewMatrix); // Set Modeview matrix

    return true;
  }
public:
  // Consteructor
  CAnchorDD_OpenGL()
    :cxxlObject(Spirit_Easy)
  {
  }

  // Desteructor
  virtual ~CAnchorDD_OpenGL()
  {
  }


};

cxxlObject *cxxlFASTCALL New_CAnchorDD_OpenGL()
{
  return new CAnchorDD_OpenGL;
}